import com.google.appengine.api.datastore.*
import static com.google.appengine.api.datastore.FetchOptions.Builder.*

def latestSnippets = []

if ('latestSnippets' in memcache) {
	latestSnippets = memcache['latestSnippets']
} else {
	def query = new Query("Snippet")
	query.addSort("createdDate", Query.SortDirection.DESCENDING)
	PreparedQuery preparedQuery = datastore.prepare(query)
	latestSnippets = preparedQuery.asList( withLimit(10) )
	memcache['latestSnippets'] = latestSnippets 
}
request['snippets'] = latestSnippets
forward '/list.gtpl'